#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string A,B;
int a,b;//10000000
int monthDay[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool isLeap(int year)
{
	return (year%400==0||(year%4==0&&year%100!=0));
}
//bool ValidDate(int date)
//{
//	int year=date/10000,mounth=(date/100)%100,day=date%100;
//	//cout<<year<<mounth<<day<<endl;
//	
//	if(mounth>12)
//	return false;
//	else if(mounth==12&&mounth==10&&mounth==8&&mounth==7&&mounth==5&&mounth==3&&mounth==1)
//	return mouthDay[mounth]>=day;
//	else if(mounth==2)
//	{
//		if(isLeap(year))
//		return day<=mouthDay[2]+1;
//		else return day<=mouthDay[2];
//	}
//	else
//	return mouthDay[mounth]>=day;
//	
//	
//	return false;
//}
bool ValidDate(int date) {
    int year = date / 10000;
    int month = (date / 100) % 100;
    int day = date % 100;
    
    if (month < 1 || month > 12) return false;
    if (day < 1) return false;
    
    if (month == 2) {
        int maxDay = monthDay[2] + (isLeap(year) ? 1 : 0);
        return day <= maxDay;
    } else {
        return day <= monthDay[month];
    }
}

int main()
{
	cin>>A>>B;
	a=stoi(A);
	b=stoi(B);
	//cout<<a<<' '<<b<<endl;
	int count=0;
	for(int i=a;i<=b;i++)
	{
		A=to_string(i);
		string tempA=A;
		reverse(A.begin(),A.end());
		//cout<<tempA<<' '<<A;
		if(tempA==A)
		{
			if(ValidDate(i))
			{
				count++;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}
